
import Vue from 'vue';

import VueRouter from 'vue-router'

// 引入各个组件
import Home from '../pages/Home.vue'
import About from '../pages/About.vue'
import News from '../pages/News.vue'
import Message from '../pages/Message.vue'
import Detail from '../pages/Detail.vue'

Vue.use(VueRouter)

// 创建并暴露一个路由器
export default new VueRouter({
  mode: 'history',
  //routes中配置一组一组的路由规则
  routes: [
    {
      path: '/about',
      component: About,
    },
    {
      path: '/home',
      component: Home,
      // 二级路由
      children: [
        {
          name: 'xinwen',
          path: 'news',
          component: News
        },
        {
          path: 'message',
          component: Message,
          // 三级路由
          children: [
            {
              name: 'xiang',
              path: 'detail',
              component: Detail,
              props(a) {
                return a.query
              },
              // props: true
            }
          ]
        },
      ]
    }
  ]
})